<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>构造方法和析构方法得联系</title>
</head>
<body>
	<?php
  
  /**
  * 构造方法做成员初始化得工作，当创建一个对象的时候，构造方法就会被自动调用一次。
  */
  class Person 
  {    var $name;
       var $age;
       var $sex;

      function  __construct($name,$age,$sex){
      $this->name=$name;       
      $this->age=$age; 
      $this->sex=$sex; 
      }
       function __destruct(){
         echo "zaijian:" .$this->name."<br>";


       }
     function say(){
        echo "my name is".$this->name."my age is".$this->age."my sex is".$this->sex."<br>";

     }
      function eat(){
        echo "这个人在说话"."<br>";
     }
      function run(){
     }	
  }
   $p1=new Person("zhangsan",20,"male ");
   $p2=new Person(" lisi",201,"male ");
   $p3=new Person("wangwu",210,"male ");
   $p1->say();
   $p1=null;!
   $p2->say();
   $p3->say();
	?>
</body>
</html>